package com.zte.claa.inficombo.csa.app.util;

import java.util.List;

import com.zte.claa.inficombo.csa.app.model.dev.DevBase;
import com.zte.claa.inficombo.csa.app.service.cache.CacheRedisManager;
import com.zte.claa.inficombo.csa.app.service.csa.impl.BaseCacheManager;
import com.zte.claa.inficombo.share.model.logicresdev.LogicResDev;
import com.zte.claa.inficombo.share.model.persondev.PersonJobDev;


public class LocUtils {
	
	public static String getDevName(String deveui) {
		try {
			CacheRedisManager cacheRedisManager = SpringBeans.getBean(CacheRedisManager.class);
			BaseCacheManager baseCacheManager = SpringBeans.getBean(BaseCacheManager.class);
			List<PersonJobDev> person = cacheRedisManager.getPersonJobByDev(deveui); // 先查询关联的人员
			if (person != null && person.size() > 0) {
				return person.get(0).getPersonname();
			} else {
				List<LogicResDev> logic = cacheRedisManager.getLogicResDevByDev(deveui); // 再查询逻辑设施
				if (logic != null && logic.size() > 0) {
					return logic.get(0).getResname();
				} 
				else {
					DevBase devBase = baseCacheManager.getDev(deveui);
					if(devBase != null){
						return devBase.getDevName();
					}
					return "-";
				}
			}
		} catch (Exception e) {
			return "-";
		}
	}
}
